package com.liehu.sms.listener;

import java.util.ArrayList;
import java.util.List;

public class test {
    public static void main(String[] args) {
        List<String> employeeList= new ArrayList<>();
        employeeList.add("a");
        employeeList.add("b");
        employeeList.add("c");
        employeeList.add("d");
        System.out.println(employeeList.get(0));
        System.out.println(employeeList.get(1));
        System.out.println(employeeList.get(2));
        System.out.println(employeeList.get(3));
        System.out.println("-------------");



      /*  System.out.println("list1:"+list);
        for(int i=0;i<list.size();i++){
            if(i == 0){
                list.add(list.get(i));
            }else{
                System.out.println("list:"+i+":"+list.get(i));
                list.set(i-1,list.get(i));
              if(i == list.size()-1){
                  list.remove(list.size()-1);
              }
            }

        }
        System.out.println("list2:"+list);*/

        int num = -1;
        //2.1.循环遍历集合
        for(int i=0;i<employeeList.size();i++){
            //2.2如果循环遍历的
            if("b".equals(employeeList.get(i))){
                num = i;//标识位置
                break;//停止循环
            }
        }
        //3.1获得了下标后，将该员工剔除
        System.out.println("num:"+num);
        if(num != -1){
            for(int i=num;i<employeeList.size();i++){
                //3.2剔除该员工
                if(i == num){
                    employeeList.remove(num);
                    // 3.3将集合后一位前移一位
                }







            }
        }
        System.out.println(employeeList.get(0));
        System.out.println(employeeList.get(1));
        System.out.println(employeeList.get(2));

    }
}
